package com.xuxin.baby.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xuxin.baby.R;
import com.xuxin.baby.bean.CategoryBean;

import org.jetbrains.annotations.NotNull;

/**
 * Created by xu_xin
 * Created on 2020.08.04 0004
 * 课程分类
 */
public class TeachGroupAdapter extends BaseQuickAdapter<CategoryBean.ResultBean, BaseViewHolder> {
    private int position;

    public void setPosition(int position) {
        this.position = position;
        notifyDataSetChanged();
    }

    public int getPosition() {
        return position;
    }

    public TeachGroupAdapter() {
        super(R.layout.item_teach_group);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, CategoryBean.ResultBean item) {
        holder.setText(R.id.item_teach_group_name, item.getCategoryName());
        LinearLayout item_teach_group = holder.getView(R.id.item_teach_group);
        ImageView item_teach_group_image = holder.getView(R.id.item_teach_group_image);
        if (position == holder.getAdapterPosition()) {
            item_teach_group.setBackgroundResource(R.color.colorWhite);
            item_teach_group_image.setVisibility(View.VISIBLE);
        } else {
            item_teach_group.setBackgroundResource(R.color.colorBackground);
            item_teach_group_image.setVisibility(View.INVISIBLE);
        }
    }
}